﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "Client";
            //1
            Socket socket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            //2
            Thread.Sleep(3000);
            socket.Connect(IPAddress.Parse("127.0.0.1"), 12345);

            //3
            Thread.Sleep(3000);
            socket.Send(ASCIIEncoding.ASCII.GetBytes("Hello, server!!!"));

            byte[] buffer = new byte[255];
            int count = socket.Receive(buffer);
            Console.WriteLine(ASCIIEncoding.ASCII.GetString(buffer));

            //4
            socket.Shutdown( SocketShutdown.Both);
            socket.Close();
        }
    }
}
